package com.example.sfm.pojo.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Range;
import org.hibernate.validator.constraints.URL;

@Data
@Accessors(chain = true)
@Schema(description = "用户创建传输对象")
public class UserCreateDto {
    @Schema(description = "用户名", deprecated = true)
    @NotBlank
    @Size(min = 4, max = 20)
    @Pattern(regexp = "^[a-zA-Z0-9_]+$", message = "只允许字母、数字和下划线")
    private String username;

    @Schema(description = "学号/工号")
    @Size(max = 15)
    @NotBlank
    private String studentId;

    @Schema(description = "密码", deprecated = true)
    @NotBlank @Size(min = 8, max = 20)
    @Pattern(regexp = "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d@$!%*#?&]{8,}$",
            message = "至少包含字母和数字")
    private String password;

    @Schema(description = "真实姓名", deprecated = true)
    @NotBlank @Size(max = 50)
    private String fullName;

    @Schema(description = "邮箱", deprecated = true)
    @NotBlank @Email
    private String email;

    @Schema(description = "手机号", deprecated = true)
    @NotBlank @Pattern(regexp = "^1[3-9]\\d{9}$")
    private String phone;

    @Schema(description = "角色（0=管理员,1=教师,2=学生）", deprecated = true)
    @Range(min = 0, max = 2)
    private Integer role;

    @URL
    @Schema(description = "头像URL")
    private String avatar;
}
